import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HashMap<String, Integer> map = new HashMap<>();
        List<String> list = new LinkedList<>();
        Set<String> set = new HashSet<>();
        while (scanner.hasNext()) {
            String str = scanner.nextLine();
            if(set.contains(str)) {
                continue;
            }
            String[] value = str.split("\\\\");
            String tail = value[value.length-1];
            if(tail.length() > 16) {
                tail = tail.substring(tail.length()-16);
            }
            //判断是否记录过
            if(map.containsKey(tail)) {
                map.put(tail,map.get(tail) + 1);
            }else {
                list.add(str);
                map.put(tail, 1);
            }
            //容量超出限制
            while (list.size()>8) {
                String tmp = list.get(0);
                value = tmp.split("\\\\");
                tail = value[value.length-1];
                map.remove(tail);
                list.remove(0);
            }
            set.add(str);
        }

        for(int i = 0; i<list.size(); i++) {
            String tmp = list.get(i);
            String[] value = tmp.split("\\\\");
            String str = value[value.length-1];
            value = str.split(" ");
            if(value[0].length() > 16) {
                String tmp2 = value[0].substring(value[0].length()-16);
                System.out.print(tmp2 + " " + value[1] + " ");
            }else {
                System.out.print(str + " ");
            }
            value = str.split("\\\\");
            System.out.println(map.get(value[value.length-1]));
        }
    }
}
